package com.mf.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mf.common.dao.impl.BaseDaoImpl;
import com.mf.dao.KullaniciDAO;
import com.mf.model.Kullanici;

@Repository
public class KullaniciDAOImpl extends BaseDaoImpl implements KullaniciDAO {

	@Autowired
	SessionFactory sessionFactory;

	public Kullanici getKullanici(String mail) {

		Criteria criteria = sessionFactory.openSession().createCriteria(Kullanici.class);
		criteria.add(Restrictions.eq("mail", mail));
		criteria.add(Restrictions.isNull("faceId"));

		if (criteria.list() == null || criteria.list().size() == 0)
			return null;
		return (Kullanici) criteria.list().get(0);
	}

}
